babl: add babl_format_exists
authorØyvind Kolås <pippin@gimp.org>
Tue, 31 Oct 2017 19:48:23 +0000 (20:48 +0100)
committerØyvind Kolås <pippin@gimp.org>
Tue, 31 Oct 2017 19:48:25 +0000 (20:48 +0100)
A function to check if a specific format - by name - is already known by babl.
Should be used in conjunction with babl_format() for user supplied format
strings.

babl/babl-format.c
babl/babl.h

index 079272c753d83b331155f01fdc84810b7d4abde1..45c62b26e817e2d2691522446825d1ffa5f1ca6d 100644 (file)
@@ -748,4 +748,13 @@ babl_format_with_space (const char *name, const Babl *space)
   return ret;
 }
 
+int
+babl_format_exists (const char *name)
+{
+  if (babl_db_exist_by_name (db, name))
+    return 1;
+  return 0;
+}
+
+
 
index 5e299a75be17530b47ff7d5837335e66acedd7f9..a45de428b3accc41fc70836b9492ccec5c9b077c 100644 (file)
@@ -156,6 +156,15 @@ char *babl_icc_get_key (const char *icc_data,
  */
 const Babl * babl_format            (const char *name);
 
+/**
+ * babl_format_exists:
+ *
+ * Returns 1 if the provided format name is known by babl or 0 if it is
+ * not. Can also be used to verify that specific extension formats are
+ * available (though this can also be inferred from the version of babl).
+ */
+int babl_format_exists              (const char *name);
+
 /**
  * babl_format_with_space:
  *